home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 5 / Apprentice-Release5.iso / Source Code / C / Applications / NoEject 1.1 / NoEject.a < prev    next >
Encoding:
Text File  |  1996-04-25  |  1.8 KB  |  89 lines  |  [TEXT/MPS ]

  1. ; (c) 1996 Dieter Spaar
  2. ; Internet: spaar@mirider.augusta.de
  3.  
  4.  
  5.          INCLUDE 'traps.a'
  6.          INCLUDE 'SysEqu.a'
  7.          INCLUDE 'SysErr.a'
  8.     
  9.  
  10. ; Install patch for SCSIDispatch
  11.  
  12. ; The patch simply checks for SCSI commands that may eject the media 
  13. ; and ignores them.
  14. ; Does not work for SCSI manager 4.3 cause it uses trap SCSIAtomic !
  15.  
  16. SCSIDispatchPatch     PROC EXPORT
  17.     
  18.          BRA.S   start
  19. next     DC.L      0             ; old trap address goes here
  20.          
  21. start    MOVE    #$A815,D0   ; SCSiDispatch
  22.          _GetToolTrapAddress ; (D0/trapNum:Word):A0\ProcPtr 
  23.          LEA     next,A1
  24.          MOVE.L     A0,(A1)
  25.          
  26.          LEA     patch,A0 
  27.          MOVE    #$A815,D0   ; SCSiDispatch
  28.          _SetToolTrapAddress ; (A0/trapAddr:ProcPtr; D0/trapNum:Word) 
  29.          RTS         
  30.  
  31. ; here is the start of the patch
  32.  
  33. patch    MOVE    4(A7),D1    ; routine selector
  34.          CMPI    #3,D1
  35.          BEQ.S   scsiCmd
  36.          
  37. go_on    LEA     next,A0     ; execute the old trap
  38.          MOVEA.L (A0),A0
  39.          JMP     (A0)
  40.  
  41. ;**********************************
  42.  
  43. scsiCmd
  44.          CMPI     #6,6(A7)      ; length of SCSI command
  45.          BNE.S     go_on
  46.          MOVEA.L 8(A7),A0      ; address of SCSI command buffer
  47.          CMPI.B     #$1E,(A0)     ; PREVENT ALLOW MEDIA REMOVAL command ?
  48.          BEQ.S     prevent
  49.          CMPI.B     #$1B,(A0)     ; START STOP UNIT command ?
  50.          BNE.S     go_on
  51.          CMPI.B     #2,4(A0)     ; STOP UNIT, request EJECT of medium, for APPLE CDROM driver
  52.          BNE.S     go_on
  53.          BRA.S     leave
  54. prevent         
  55.          CMPI.B     #0,4(A0)     ; allow removal ?
  56.          BNE.S     go_on
  57. leave         
  58.          MOVE     #0,D0         ; return no error but don't execute SCSI command
  59.          RTS         
  60.          
  61.          ENDP
  62.  
  63.  
  64.  
  65. ; return the size of the shutdown routine
  66.  
  67. GetSize     PROC EXPORT
  68.          
  69.          LEA     GetSize - SCSIDispatchPatch,A0
  70.          MOVE.L     A0,4(A7)
  71.          RTS
  72.          
  73.          ENDP
  74.  
  75.  
  76. ; return start address of the shutdown routine
  77.  
  78. GetAddr     PROC EXPORT
  79.          
  80.          LEA     SCSIDispatchPatch,A0
  81.          MOVE.L     A0,4(A7)
  82.          RTS
  83.          
  84.          ENDP
  85.  
  86.          
  87.          END    
  88.     
  89.